<?php
$host = 'localhost';
$username = ''; //数据库用户名
$password = ''; //数据库密码
$dbname = ''; //用于保存数据的数据库
$mysql = new mysqli($host, $username, $password, $dbname);
$title = $_POST['name'];
$title_id = $_POST['id'];
$author = $_POST['author'];
$version = $_POST['version'];
$num = $_POST['num'];
if ($mysql->connect_errno) {
    die('数据库连接失败：' . $mysql->connect_errno);
} else {
    $sql = "INSERT into bookinfo (book_id,book_name,author,ver,num)
    values ('$title_id','$title','$author','$version',$num)";
    $result = $mysql->query($sql);
    if ($result)
        echo "<script>alert('添加成功')</script>";
    else echo "<script>alert('添加失败')</script>";
    $mysql->close();
}
?>
<br>
<a href="addbook.html">返回继续添加</a> or <a href="homepage.html">返回首页</a>